<template>
  <el-dialog
      :title="title"
      :visible.sync="visible"
      width="600px"
      :close-on-click-modal="false"
      @closed="resetForm"
  >
    <el-form
        ref="employeeForm"
        :model="formModel"
        :rules="formRules"
        label-width="100px"
        label-position="right"
    >
      <el-form-item label="员工姓名" prop="name">
        <el-input
            v-model="formModel.name"
            placeholder="请输入员工姓名"
            clearable
        ></el-input>
      </el-form-item>
      <el-form-item label="年龄" prop="age">
        <el-input
            v-model.number="formModel.age"
            placeholder="请输入年龄"
            type="number"
            min="18"
            max="100"
        ></el-input>
      </el-form-item>
      <el-form-item label="入职日期" prop="employmentDate">
        <el-date-picker
            v-model="formModel.employmentDate"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
            style="width: 100%"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="在职状态" prop="employed">
        <el-switch
            v-model="formModel.employed"
            active-text="在职"
            inactive-text="离职"
        ></el-switch>
      </el-form-item>
      <el-form-item label="所属公司" prop="companyId">
        <el-select
            v-model="formModel.companyId"
            placeholder="请选择公司"
            filterable
            style="width: 100%"
        >
          <el-option
              v-for="company in companyOptions"
              :key="company.id"
              :label="company.name"
              :value="company.id"
          ></el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="visible=false">取 消</el-button>
      <el-button type="primary" @click="submitForm" :loading="submitting">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import Handler from './EmployeeForm.js'

export default Handler
</script>

<style scoped lang="scss">
@import './EmployeeForm.scss';
</style>
